package org.jivesoftware.smackx.commands;

import java.util.List;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smackx.Form;
import org.jivesoftware.smackx.packet.AdHocCommandData;

public abstract class AdHocCommand
{
  private AdHocCommandData data = new AdHocCommandData();

  public static SpecificErrorCondition getSpecificErrorCondition(XMPPError paramXMPPError)
  {
    SpecificErrorCondition[] arrayOfSpecificErrorCondition = SpecificErrorCondition.values();
    int i = arrayOfSpecificErrorCondition.length;
    int j = 0;
    while (true)
    {
      Object localObject;
      if (j >= i)
        localObject = null;
      while (true)
      {
        return localObject;
        SpecificErrorCondition localSpecificErrorCondition = arrayOfSpecificErrorCondition[j];
        if (paramXMPPError.getExtension(localSpecificErrorCondition.toString(), "http://jabber.org/protocol/commands") == null)
          break;
        localObject = localSpecificErrorCondition;
      }
      ++j;
    }
  }

  protected void addActionAvailable(Action paramAction)
  {
    this.data.addAction(paramAction);
  }

  protected void addNote(AdHocCommandNote paramAdHocCommandNote)
  {
    this.data.addNote(paramAdHocCommandNote);
  }

  public abstract void cancel()
    throws XMPPException;

  public abstract void complete(Form paramForm)
    throws XMPPException;

  public abstract void execute()
    throws XMPPException;

  protected List<Action> getActions()
  {
    return this.data.getActions();
  }

  AdHocCommandData getData()
  {
    return this.data;
  }

  protected Action getExecuteAction()
  {
    return this.data.getExecuteAction();
  }

  public Form getForm()
  {
    Form localForm;
    if (this.data.getForm() == null)
      localForm = null;
    while (true)
    {
      return localForm;
      localForm = new Form(this.data.getForm());
    }
  }

  public String getName()
  {
    return this.data.getName();
  }

  public String getNode()
  {
    return this.data.getNode();
  }

  public List<AdHocCommandNote> getNotes()
  {
    return this.data.getNotes();
  }

  public abstract String getOwnerJID();

  public String getRaw()
  {
    return this.data.getChildElementXML();
  }

  public Status getStatus()
  {
    return this.data.getStatus();
  }

  protected boolean isValidAction(Action paramAction)
  {
    int i;
    if ((!(getActions().contains(paramAction))) && (!(Action.cancel.equals(paramAction))))
      i = 0;
    while (true)
    {
      return i;
      i = 1;
    }
  }

  public abstract void next(Form paramForm)
    throws XMPPException;

  public abstract void prev()
    throws XMPPException;

  void setData(AdHocCommandData paramAdHocCommandData)
  {
    this.data = paramAdHocCommandData;
  }

  protected void setExecuteAction(Action paramAction)
  {
    this.data.setExecuteAction(paramAction);
  }

  protected void setForm(Form paramForm)
  {
    this.data.setForm(paramForm.getDataFormToSend());
  }

  public void setName(String paramString)
  {
    this.data.setName(paramString);
  }

  public void setNode(String paramString)
  {
    this.data.setNode(paramString);
  }

  public static enum Action
  {
    static
    {
      cancel = new Action("cancel", 1);
      prev = new Action("prev", 2);
      next = new Action("next", 3);
      complete = new Action("complete", 4);
      unknown = new Action("unknown", 5);
      Action[] arrayOfAction = new Action[6];
      arrayOfAction[0] = execute;
      arrayOfAction[1] = cancel;
      arrayOfAction[2] = prev;
      arrayOfAction[3] = next;
      arrayOfAction[4] = complete;
      arrayOfAction[5] = unknown;
      ENUM$VALUES = arrayOfAction;
    }
  }

  public static enum SpecificErrorCondition
  {
    private String value;

    static
    {
      badLocale = new SpecificErrorCondition("badLocale", 2, "bad-locale");
      badPayload = new SpecificErrorCondition("badPayload", 3, "bad-payload");
      badSessionid = new SpecificErrorCondition("badSessionid", 4, "bad-sessionid");
      sessionExpired = new SpecificErrorCondition("sessionExpired", 5, "session-expired");
      SpecificErrorCondition[] arrayOfSpecificErrorCondition = new SpecificErrorCondition[6];
      arrayOfSpecificErrorCondition[0] = badAction;
      arrayOfSpecificErrorCondition[1] = malformedAction;
      arrayOfSpecificErrorCondition[2] = badLocale;
      arrayOfSpecificErrorCondition[3] = badPayload;
      arrayOfSpecificErrorCondition[4] = badSessionid;
      arrayOfSpecificErrorCondition[5] = sessionExpired;
      ENUM$VALUES = arrayOfSpecificErrorCondition;
    }

    public String toString()
    {
      return this.value;
    }
  }

  public static enum Status
  {
    static
    {
      completed = new Status("completed", 1);
      canceled = new Status("canceled", 2);
      Status[] arrayOfStatus = new Status[3];
      arrayOfStatus[0] = executing;
      arrayOfStatus[1] = completed;
      arrayOfStatus[2] = canceled;
      ENUM$VALUES = arrayOfStatus;
    }
  }
}